package com.house.twohouse.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.house.twohouse.entity.TwohouseEntity;
import com.house.twohouse.service.TwohouseService;
import com.house.common.utils.PageUtils;
import com.house.common.utils.R;



/**
 * 
 *
 * @author wzh
 * @email sunlightcs@gmail.com
 * @date 2022-04-25 20:50:10
 */
@RestController
@RequestMapping("twohouse/twohouse")
public class TwohouseController {
    @Autowired
    private TwohouseService twohouseService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = twohouseService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{twohouseId}")
    public R info(@PathVariable("twohouseId") Integer twohouseId){
		TwohouseEntity twohouse = twohouseService.getById(twohouseId);

        return R.ok().put("twohouse", twohouse);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody TwohouseEntity twohouse){
		twohouseService.save(twohouse);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody TwohouseEntity twohouse){
		twohouseService.updateById(twohouse);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] twohouseIds){
		twohouseService.removeByIds(Arrays.asList(twohouseIds));

        return R.ok();
    }

}
